package com.hua.utils;


import org.apache.poi.xwpf.usermodel.*;
import org.apache.xmlbeans.XmlException;

import org.springframework.stereotype.Component;

import java.io.*;



/**
 * word写进内容编辑
 */
@Component
public class WordDoc {
    public String Write() throws IOException {
//        XWPFDocument document = new XWPFDocument();
//        FileOutputStream out = new FileOutputStream(new File("E:/方案.doc"));
//        //添加标题
//        XWPFParagraph titleParagraph = document.createParagraph();
//        //设置段落居中
//        titleParagraph.setAlignment(ParagraphAlignment.CENTER);
//        XWPFRun titleParagraphRun = titleParagraph.createRun();
//        titleParagraphRun.setText("技术方案");
//        titleParagraphRun.setColor("000000");
//        titleParagraphRun.setFontSize(20);
//
//        //段落
//        XWPFParagraph Paragraph = document.createParagraph();
//        XWPFRun run = Paragraph.createRun();
//        run.setText("第一章  工程概括");
//        run.setColor("696969");
//        run.setFontSize(18);
//        //设置段落背景颜色
////        CTShd cTShd = run.getCTR().addNewRPr().addNewShd();
////        cTShd.setVal(STShd.CLEAR);
////        cTShd.setFill("97FFFF");
//        //换行
//        XWPFParagraph paragraph = document.createParagraph();
//        XWPFRun paragraphRun = paragraph.createRun();
//        paragraphRun.setText("\r");
//
//        //段落
//        XWPFParagraph Paragraph1 = document.createParagraph();
//        XWPFRun run1 = Paragraph1.createRun();
//        run1.setText("一、危大工程概况和特点");
//        run1.setColor("696969");
//        run1.setFontSize(16);
//        //换行
//        XWPFParagraph paragraph1 = document.createParagraph();
//        XWPFRun paragraphRun1 = paragraph1.createRun();
//        paragraphRun1.setText("\r");
//
//        //段落
//        XWPFParagraph Paragraph2 = document.createParagraph();
//        XWPFRun run2 = Paragraph2.createRun();
//        run2.setText("【工程概况应针对该危险性较大的分部分项工程的特点及要求进行编写】");
//        run2.setColor("696969");
//        run2.setFontSize(16);
//
//        //换行
//        XWPFParagraph paragraph2 = document.createParagraph();
//        XWPFRun paragraphRun2 = paragraph2.createRun();
//        paragraphRun2.setText("\r");
//
//        //段落
//        XWPFParagraph Paragraph3 = document.createParagraph();
//        XWPFRun run3 = Paragraph3.createRun();
//        run3.setText("1、工程基本情况");
//        run3.setColor("696969");
//        run3.setFontSize(16);
//
//
//
//
//        //工程基本情况表格
//        XWPFTable infoTable = document.createTable();
//        //去表格边框
////        infoTable.getCTTbl().getTblPr().unsetTblBorders();
//
//
//        //列宽自动分割
////        CTTblWidth infoTableWidth = infoTable.getCTTbl().addNewTblPr().addNewTblW();
////        infoTableWidth.setType(STTblWidth.DXA);
////        infoTableWidth.setW(BigInteger.valueOf(9072));
//
//
//        //表格第一行
//        XWPFTableRow infoTableRowOne = infoTable.getRow(0);
//        infoTableRowOne.getCell(0).setText("工程名称");
//        infoTableRowOne.addNewTableCell().setText("0");
//        infoTableRowOne.addNewTableCell().setText("工地地点");
//        infoTableRowOne.addNewTableCell().setText("0");
//        //表格第二行
//        XWPFTableRow infoTableRowTwo = infoTable.createRow();
//        infoTableRowTwo.getCell(0).setText("建筑面积(m2)");
//        infoTableRowTwo.getCell(1).setText("0");
//        infoTableRowTwo.getCell(2).setText("建筑高度(m)");
//        infoTableRowTwo.getCell(3).setText("0");
//
//        //表格第三行
//        XWPFTableRow infoTableRowThree = infoTable.createRow();
//        infoTableRowThree.getCell(0).setText("结构类型");
//        infoTableRowThree.getCell(1).setText("0");
//        infoTableRowThree.getCell(2).setText("基础类型");
//        infoTableRowThree.getCell(3).setText("0");
//
//        //表格第四行
//        XWPFTableRow infoTableRowFour = infoTable.createRow();
//        infoTableRowFour.getCell(0).setText("地上层数");
//        infoTableRowFour.getCell(1).setText("0");
//        infoTableRowFour.getCell(2).setText("地下层数");
//        infoTableRowFour.getCell(3).setText("0");
//
//        //表格第五行
//        XWPFTableRow infoTableRowFive = infoTable.createRow();
//        infoTableRowFive.getCell(0).setText("标准层层高(m)");
//        infoTableRowFive.getCell(1).setText("0");
//        infoTableRowFive.getCell(2).setText("其它主要层高(m)");
//        infoTableRowFive.getCell(3).setText("0");
//
//
//        //两个表格之间加个换行
//        //换行
////        XWPFParagraph paragraph3 = document.createParagraph();
////        XWPFRun paragraphRun3 = paragraph3.createRun();
////        paragraphRun3.setText("\r");
//
//        //段落
//        XWPFParagraph Paragraph4 = document.createParagraph();
//        XWPFRun run4 = Paragraph4.createRun();
//        run4.setText("2、工程基本情况");
//        run4.setColor("696969");
//        run4.setFontSize(16);
//
//        //2、各责任主体名称
//        XWPFTable ComTable = document.createTable();
//
//        //换行
//        XWPFParagraph paragraph4 = document.createParagraph();
//        XWPFRun paragraphRun4 = paragraph4.createRun();
//        paragraphRun4.setText("\r");
//
//
//        //列宽自动分割
////        CTTblWidth comTableWidth = ComTable.getCTTbl().addNewTblPr().addNewTblW();
////        comTableWidth.setType(STTblWidth.DXA);
////        comTableWidth.setW(BigInteger.valueOf(9072));
//
//        //表格第一行
//        XWPFTableRow comTableRowOne = ComTable.getRow(0);
//        comTableRowOne.getCell(0).setText("建设单位");
//        comTableRowOne.addNewTableCell().setText("");
//        comTableRowOne.addNewTableCell().setText("设计单位");
//        comTableRowOne.addNewTableCell().setText("");
//
//        //表格第二行
//        XWPFTableRow comTableRowTwo = ComTable.createRow();
//        comTableRowTwo.getCell(0).setText("施工单位");
//        comTableRowTwo.getCell(1).setText("");
//        comTableRowTwo.getCell(2).setText("监理单位");
//        comTableRowTwo.getCell(3).setText("");
//
//        //表格第三行
//        XWPFTableRow comTableRowThree = ComTable.createRow();
//        comTableRowThree.getCell(0).setText("项目经理");
//        comTableRowThree.getCell(1).setText("");
//        comTableRowThree.getCell(2).setText("总监理工程师");
//        comTableRowThree.getCell(3).setText("");
//
//        //表格第4行
//        XWPFTableRow comTableRowFour = ComTable.createRow();
//        comTableRowFour.getCell(0).setText("技术负责人");
//        comTableRowFour.getCell(1).setText("");
//        comTableRowFour.getCell(2).setText("专业监理工程师");
//        comTableRowFour.getCell(3).setText("");




        //添加页脚



//        document.write(out);
//        out.close();
        System.out.println("create_table document written success.");
        String aa ="a";
        return aa;
    }


}
